home *** CD-ROM | disk | FTP | other *** search
- High Memory RAMDisk
-
- The following letter from Skip Chambers, Carrollton, TX, along
- with the editor's (C. Petzold) remarks appeared in the Power User
- column of PC Magazine, Vol 4 No 21 October 15, 1985.
-
- Here's the secret for installing 128K additional RAM in the IBM PC
- and XT, over and above the normal 640K limit. The added memory can be
- used for a RAMdisk.
- The first step is to install 128K RAM in a standard IBM 64/256K
- Memory Expansion Option board. Set the DIP switches thus:
-
- 1 2 3 4 5 6 7 8
- OFF OFF ON OFF OFF ON OFF OFF
-
- This configures the board for 128K at segment address D000h and E000h.
- Next, you must modify the DOS 2.0/2.1 RAMdisk program to use this
- extra memory rather than normal user RAM. Since a manual reboot will
- not clear out this memory, I've provided some additional code to retain
- the contents of the RAMdisk and not reinitialize it if a manual reboot
- is in progress.
- Skip Chambers
-
- Editor's Remarks:
-
- Although this extra memory space cannot normally be recognized by
- programs running under DOS, as alternatives to using it for a RAMdisk,
- you could also use it for a print buffer or as a BLOAD area to hold
- machine language subroutines under BASIC.
- I find this very exciting. Until recently, I have used a 160K
- RAMdisk, mostly for WordStar. But what with the size of DOS 3.1 and an
- AUTOEXEC full of remain-resident programs, I gobble up 128K at boot
- time. In order to run programs requiring 512K, I had to give up my
- RAMdisk. Now I've got one back.
- Although the RAMdisk program we'll be modifying is taken from the
- DOS 2.x manuals, the changes work both under DOS 2.x and 3.x.
- Let's step back a minute to see why this trick is so neat.
- The 8088 microprocessor used in the IBM PC and PC-XT can directly
- address 1,048,576 bytes of memoty or 1,024K. But only the first 640K
- is allocated for random-access (or user) memory. The other 384K is
- reserved by IBM for other purposes.
- At the very top of memory, 64K is allocated for the ROM BIOS and
- ROM BASIC interpreter. Just above the 640K random-access memory, 128K
- is reserved for video display memory. While the monochrome display
- actually requires only 4K and the standard color/graphics display uses
- only 16K of this 128K reserved area, the IBM Enhanced Graphics Adapter
- (EGA) lays claim to much more of it.
- Following the video display memory is 64K for additional ROMs,
- such as those containing the BIOS support for the PC-XT hard disk and
- the EGA.
- This leaves another 128K, which IBM allocated for additional ROM
- expansion and which is, indeed, the memory area used for PCjr ROM
- cartridges. But on the PC and PC-XT, this area will normally be free
- for you to install another random-access memory board. If you have a
- non-IBM hard disk or other heavy hardware in your system, however, you
- must check to see if it addresses ROM segments D000h or E000h. If so,
- you're already using this area, and so you won't be able to install the
- additional memory described here.
- You'll also need a memory board that can be switched to segments
- D000h and E000h. Some multifunction boards -- the popular AST Six-Pak-
- Plux, for instance -- cannot themselves be switched to address an area
- above 640K. However, if you're up to 640K, you probably already have
- a multifunction board, so a straight memory board such as the IBM
- 64/256K Memory Expansion Option is ideal.
- To install a 128K RAMdisk at this address, you'll also need either
- the DOS 2.0 or 2.1 Technical Reference manual (the IBM RAMdisk program
- is found at the end of the chapter on device drivers), plus a macro
- assembler, such as those from IBM or Microsoft.
- Type in the "Sample Device Driver" program, calling the file
- EDISK.ASM. (EDISK stands for "Extra Memory Disk.") Do not type the
- numbers on the left side of the IBM listing: enter only that part of
- each line that is even with the top-most semicolon. Further, do not
- type in any of the lines that have a plus sign just to the left of
- them (they're toward the end of the listing). These are lines created
- by teh assembler when expanding the macros.
- Assemble, ling, and convert your EDISK.ASM into a .SYS file by
- using the following commands:
-
- MASM EDISK,,;
- LINK EDISK;
- EXE2BIN EDISK EDISK.SYS
-
- Success means getting only one error message from MASM, namely,
- that there is no stack segment. Ignore it. MASM will also create a
- file called EDISK.LST. To assure yourself that you typed the program
- in correctly, check the addresses and assembled machine code at the
- left of the EDISK.LST listing with the program listing in the DOS
- manual.
- The next step is to include a line in a CONFIG.SYS file in the
- root directory of your boot disk. This line is: DEVICE=EDISK.SYS.
- EDISK will then be loaded at boot time. When first installing a
- device driver such as EDICK, you should have two different ways to
- boot your system (such as a disk without EDISK and a disk with EDISK),
- because if errors in the EDISK program crash your system, you need some
- way of booting without it.
- Unmodified, EDISK.SYS simply creates a 180K RAMdisk on your system
- in regular user memory. This disk will have a drive letter one above
- your normal drive. You may use this disk like any other except that
- the contents will be destroyed if the PC is turned off or if you
- reboot.
- Figures 1 through 4 show the changes to make in EDISK.ASM so that
- it will use the extra random-access memory at segments D000h and E000h.
- The line numbers are consistent with the line numbers in the DOS 2.0
- and 2.1 manuals. Line numbers with decimals, such as 230.1, are
- insertions; that line would go between line 230 and 231. Otherwise,
- the lines replace those in the DOS 2.x program.
- Figure 1 shows a few changes you should make even if you only want
- to set up a normal IBM RAMdisk. These changes take care of the most
- blatant bugs and allow the program to be assembled under later versions
- of the IBM or Microsoft Macro Assembler.
- Figure 2 shows the changes used to shorten the RAMdisk to 256
- sectors and to place it at segment addresses D000h and E000h. Each
- sector is 512 bytes, so total disk space will be reduced from IBM's
- 180K to the 128K you have available.
- This is really all that's needed, but you might be in for a
- surprise if you read some RAMdisk sectors directly from DEBUG or run
- Norton Utilities DISKTEST program on the new RAMdisk. You'll probably
- get a parity check error, since the added memory was not properly
- initialized by the BIOS during boot time. Initialization is easy,
- however: all you do is write something to it. Figure 3 shows the
- added steps to initialize the new memory properly.
- Figure 4 shows the additions to preserve the disk contents
- during a "warm boot." Turning on the PC's switch is sometimes called
- a cold start; resetting the computer with the Ctrl-Alt-Del key
- sequence represents a hot (or warm) start. The code shown in Figure 4
- preserves the contents of the disk when you use a keyboard reset,
- though they will be lost, of course, if you turn the machine off with
- the power switch.
- By the way, you should not study the RAMdisk program in the DOS
- 2.x manual in hopes of learning good assembler programming practice!
- The listing is excessively macroed and equated to the point where it
- is virtually unreadable. Moreover, the most important types of
- equates -- those that would allow the user to change the number of
- sectors or the sector size with one statement at the top of the
- program -- are missing.
- - - - - -
- Figure 1:
-
- 102 USER_DTA DW ?,? ;CORRECTION
- 230.1 PUSH CS ;ADDITION
- 230.2 POP DS ;ADDITION
- 230.3 LES BX,DWORD PTR RH_OFF ;ADDITION
- - - - - -
- Figure 2:
-
- 92 DW 256 ;TOTAL NUMBER OF SECTORS
- 115 DW 256 ;TOTAL NUMBER OF SECTORS
- 247 MOV CS:VDISK_PTR,0D000H ;RAM DISK SEGMENT
- 248 ;DELETE LINE
- 249 ;DELETE LINE
- - - - - -
- Figure 3:
-
- 257.1 MOV CX,8000H ;NUMBER OF BYTES
- 257.2 SUB AX,AX ;BYTE TO WRITE
- 257.3 REP STOSW ;1ST SEGMENT DONE
- 257.4 MOV CX,ES ;ES TO NEXT SEGMENT
- 257.5 ADD CX,1000H
- 257.6 MOV ES,CX
- 257.7 MOV CX,8000H ;NUMBER OF BYTES
- 257.8 REP STOSW ;2ND SEGMENT DONE
- 257.9 MOV ES,CS:VDISK_PTR ;BACK TO 1ST SEGMENT
- - - - - -
-
-
- Figure 4:
-
- 255.1 PUSH DS ;SAVE DS
- 255.2 MOV AX,40H ;BIOS DATA SEGMENT
- 255.3 MOV DS,AX ;SET UP SEGMENT REGISTER
- 255.4 CMP WORD PTR DS:[0072H],1234H
- 255.5 POP DS ;CHECK RESET MODE
- 255.6 JNZ COLD_START ;INITIALIZE DISK
- 255.7 JMP HOT_START ;SKIP IF KEYBOARD RESET
- 255.8 COLD_START:
-
-
- 290.1 LEA DX,COLD_MSG
- 290.2 JMP SHORT MESSAGE
- 290.3 COLD_MSG DB 13,10,"Hi-RAM disk installed.",13,10,"$"
- 290.4 HOT_MSG DB 13,10,"Hi-RAM disk preserved.",13,10,"$"
- 290.5 HOT_START:LEA DX,HOT_MSG ;MESSAGE TO PRINT
- 290.6 MESSAGE: PUSH CS ;CURRENT SEGMENT
- 290.7 POP DS ;SET DS TO IT
- 290.8 MOV AH,9 ;DOS PRINT STRING CALL
- 290.9 INT 21H ;PRINT STRING
-
-